package secondStage.part5.网络编程.TCP通信程序;

import java.io.*;
import java.net.Socket;

/**
 * @ClassName: [ClientTcpSendTest]
 * @Description: TCP通信程序，发送信息
 * @Author: [黄劲松]
 * @CreateDate: [2021-04-06]
 * @Version: [v1.0]
 */
//客户端:数据来自于键盘录入,直到输入的数据886. 发送数据结束
public class ClientTcpSendTest2 {
    public static void main(String[] args) throws IOException {
        //创建客户端的Socket对象(Socket)
        Socket s = new Socket("192.168.1.115", 8080);
        //数据来自于键盘录入,直到输入的数据886. 发送数据结束
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //封装输出流对象
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        String line;
        while ((line=br.readLine())!= null){
            if ("886".equals(line)){
                break;
            }
            //获取输出流，写数据
//            OutputStream os = s.getOutputStream();
//            os.write(line.getBytes());
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        s.close();
    }
}
